-- Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
--
-- this file licensed under the Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
--
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-- PURPOSE.
-- See the Mulan PSL v2 for more details.
--
-- Author: auto generate
-- Create: 2025-11-19
-- Description: DO NOT EDIT; Code generated by "service.lua.mako"
local app_base = require 'mc.service_app_base'
local class = require 'mc.class'
local mdb = require 'mc.mdb'
local context = require 'mc.context'

local cls_mng = require 'mc.class_mgnt'
local model = require 'class.model'

local open_db = require 'dcmid.db'
local orm_classes = require 'dcmid.orm_classes'
local ok, datas = pcall(require, 'dcmid.datas')
if not ok then
    -- 如果没有datas配置，证明当前组件不需要datas，仅打开数据库
    datas = nil
end

local dcmid_service = class(app_base.Service)

dcmid_service.subscriptions = {}
function dcmid_service:SubscribeAll()
    if self.has_subscribe_all then
        return
    end

    for i = 1, #self.subscriptions do
        self.subscriptions[i](self)
    end

    self.has_subscribe_all = true
end

dcmid_service.package = 'dcmid'

function dcmid_service:get_bus()
    return self.bus
end

function dcmid_service:ctor()
    if not self.name then
        self.name = dcmid_service.package
    end
    self.signal_slots = {}
    self.db = open_db(':memory:', datas)
    orm_classes.init(self.db)
    self.bus:request_name(app_base.Service.get_service_name(self.name))

    model.init(self.bus)

    dcmid_service.bus = self.bus
end

function dcmid_service:pre_init()
    if dcmid_service.super.pre_init then
        dcmid_service.super.pre_init(self)
    end
end

function dcmid_service:init()
    dcmid_service.super.init(self)
    self:SubscribeAll()

end

return dcmid_service
